package com.zhong.learning.auto_paper.dto;

import com.our.learning.infrastructure.po.Paper;
import lombok.Data;
import lombok.ToString;

import java.util.List;

/**
 * 自动组卷接收的内容
 * @author zhong
 * @date 2023/6/20
 */
@Data
@ToString
public class AutoPaperDTO {
    private Integer id;
    private String name;
    private Integer sumScore;
    // 0--easy,1--medium,2--hard
    private Integer difficulty;
    private List<QuestionDTO> questions;
    public AutoPaperDTO() {
    }

    public Paper toAutoPaper() {
        Paper paper = new Paper();
        paper.setId(id);
        paper.setName(name);
        paper.setSumScore(sumScore);
        int questionNum = 0;
        for (QuestionDTO question : questions) {
            questionNum += question.getNum();
        }
        paper.setQuestionNum(questionNum);
        paper.setType(2);
        paper.setDifficulty(this.getDifficulty());
        return paper;
    }
}
